home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / jpl_c.zip / GETL.C < prev    next >
Text File  |  1986-05-18  |  1KB  |  34 lines

  1. /* 1.1  01-08-86                        (getl.c)
  2.  ************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1986        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10.  
  11. #define MAXLDIGITS    11    /* Maximum digits in a long, + 1.    */
  12.  
  13. /************************************************************************/
  14.     long
  15. getl(prompt, check, low, high)    /* Print prompt on stdout, then get and
  16.                    return long integer input from stdin.
  17.                    If check is true, verify bounds.    */
  18. /*----------------------------------------------------------------------*/
  19. STRING prompt;
  20. BOOL check;
  21. long low, high;
  22. {
  23.     long value, atol();
  24.     char s[MAXLDIGITS];
  25.  
  26.     FOREVER
  27.     {    value = atol(getns(prompt, s, MAXLDIGITS-1));
  28.         if (NOT check OR (low <= value AND value <= high))
  29.             break;
  30.         printf("\nValue out of range, please reenter:\n");
  31.     }
  32.     return (value);
  33. }
  34.